package kr.hkit.powerjava.chapter11;

class Fly{
	String name;

	@Override
	public String toString() {
		return "Fly [name=" + name + "]";
	}
	
}
public class Car {
	int speed;
	int gear;
	public String color;

	public void speedUp(int increment) {
		speed += increment;
	}

	public void speedDown(int decrement) {
		speed -= decrement;
	}

	@Override
	public String toString() {
		return String.format("Object[%s]-> Car [%s, %s, %s]", super.toString(),
				speed, gear, color);
	}

	public static void main(String[] args) {
		Car car = new Car();
		car.gear = 1;
		car.color = "red";
		car.speedUp(60);
		System.out.println(car);
		
		Object obj=car;
		System.out.println(obj.toString());
		
		Car car2=new Car();
		car2.gear=2;
		car2.color="blue";
		car.speedUp(80);
		
		Fly fly=new Fly();
		fly.name="fly01";
		
		Fly fly2=new Fly();
		fly2.name="fly02";
		
		Car[] arrCar=new Car[2];
		Fly[] arrFly=new Fly[2];
		
		arrCar[0]=car;
		arrCar[1]=car2;
		
		arrFly[0]=fly;
		arrFly[1]=fly2;
		
		prnarr(arrCar);
		prnarr(arrFly);
		
		Object[] arrObj =new Object[4];
		arrObj[0]=car;
		arrObj[1]=car2;
		arrObj[2]=fly;
		arrObj[3]=fly2;
		prnarr(arrObj);
			
//		Car car2=new Object();
	}

	private static void prnarr(Object[] arrObj) {
		for (int i = 0; i < arrObj.length; i++) {
			System.out.println(arrObj[i]);
		}
		// TODO Auto-generated method stub
		
	}

	private static void prnarr(Fly[] arrFly) {
		for (int i = 0; i < arrFly.length; i++) {
			System.out.println(arrFly[i]);
		}
		// TODO Auto-generated method stub
		
	}

	private static void prnarr(Car[] arrCar) {
		for (int i = 0; i < arrCar.length; i++) {
			System.out.println(arrCar[i]);
		}
		// TODO Auto-generated method stub
		
	}
}
